//
// Copyright (C) 2011 - 2013  Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.2 with QuantLib 1.2.1
//#include "stdafx.h"
#include "Path.h"
using namespace Cephei::QL::Methods::Montecarlo;
#include <gen/QL/TimeGrid.h>
#include <gen/QL/Math/Array.h>
using namespace Cephei::QL;
using namespace Cephei::QL::Math;
#undef HANDLE
#undef ABSTRACT
#define STRUCT
Cephei::QL::Methods::Montecarlo::CPath::CPath (Cephei::QL::ITimeGrid^ timeGrid, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Math::IArray^>^ values) 
{
	_pSpinlock = new boost::detail::spinlock ();
    CTimeGrid^ _CtimeGrid;
    CArray^ _Cvalues;
    try
    {
#ifdef HANDLE
        _phPath = NULL;
#endif
        _CtimeGrid = safe_cast<CTimeGrid^> (timeGrid);
        _CtimeGrid->Lock();
        QuantLib::TimeGrid& _timeGrid = static_cast<QuantLib::TimeGrid&> (_CtimeGrid->GetReference ()); 
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Math::IArray^>::IsSome::get (values))
        {
            _Cvalues = safe_cast<CArray^> (values->Value);
            _Cvalues->Lock();
        }
        QuantLib::Array& _values = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Math::IArray^>::IsSome::get (values) ? static_cast<QuantLib::Array&> (_Cvalues->GetReference ()) : QuantLib::Array()); //1
        _ppPath = new boost::shared_ptr<QuantLib::Path> (new QuantLib::Path ( _timeGrid,  _values ));
        
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
        if (_CtimeGrid != nullptr) _CtimeGrid->Unlock();
        if (_Cvalues != nullptr) _Cvalues->Unlock();
    }
}
Cephei::QL::Methods::Montecarlo::CPath::CPath (boost::shared_ptr<QuantLib::Path>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phPath = NULL;
#endif
	_ppPath = &childNative;
    
}
Cephei::QL::Methods::Montecarlo::CPath::CPath (QuantLib::Path& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phPath = NULL;
#endif
	_ppPath = new boost::shared_ptr<QuantLib::Path> (&childNative);
    
    _PathOwner = owner;
    
}

Cephei::QL::Methods::Montecarlo::CPath::CPath (CPath^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phPath = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppPath = new boost::shared_ptr<QuantLib::Path> (copy->GetShared());
        
    }
}
Cephei::QL::Methods::Montecarlo::CPath::CPath (PLATFORM::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phPath = NULL;
#endif
	if (!t->IsSubclassOf(CPath::typeid))
		throw REFNEW Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Methods::Montecarlo::CPath::CPath (QuantLib::Handle<QuantLib::Path>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phPath = &childNative;
	_ppPath = &static_cast<boost::shared_ptr<QuantLib::Path>>(childNative.currentLink());
    
    _PathOwner = owner;
}
Cephei::QL::Methods::Montecarlo::CPath::CPath (QuantLib::Handle<QuantLib::Path> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phPath = &childNative;
	_ppPath = &static_cast<boost::shared_ptr<QuantLib::Path>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Methods::Montecarlo::CPath::CPath (QuantLib::Path childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phPath = NULL;
#endif
	_ppPath = new boost::shared_ptr<QuantLib::Path> (new QuantLib::Path (childNative));
    
}
#endif

Cephei::QL::Methods::Montecarlo::CPath::~CPath ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppPath != NULL)
    {
	    delete _ppPath;
        _ppPath = NULL;
    }
}
Cephei::QL::Methods::Montecarlo::CPath::!CPath ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppPath != NULL)
    {
	    delete _ppPath;
    }
}
QuantLib::Path& Cephei::QL::Methods::Montecarlo::CPath::GetReference ()
{
    if (_ppPath == NULL) throw REFNEW NativeNullException ();
	return **_ppPath;
}
boost::shared_ptr<QuantLib::Path>& Cephei::QL::Methods::Montecarlo::CPath::GetShared ()
{
    if (_ppPath == NULL) throw REFNEW NativeNullException ();
	return *_ppPath;
}
QuantLib::Path* Cephei::QL::Methods::Montecarlo::CPath::GetPointer ()
{
    if (_ppPath == NULL) throw REFNEW NativeNullException ();
	return &**_ppPath;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::Path>& Cephei::QL::Methods::Montecarlo::CPath::GetHandle ()
{
	if (_phPath == NULL)
	{
		_phPath = new Handle<QuantLib::Path> (*_ppPath);
	}
	return *_phPath;
}
#endif
bool Cephei::QL::Methods::Montecarlo::CPath::HasNative () 
{
	return (_ppPath != NULL);
}

Double Cephei::QL::Methods::Montecarlo::CPath::At (UInt64 i)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Size _i = (QuantLib::Size)ValueHelper::Convert (i); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppPath)->at ( _i );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Methods::Montecarlo::CPath::Back::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppPath)->back ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Boolean Cephei::QL::Methods::Montecarlo::CPath::Empty::get ()
{
    try
    {
    	bool _rv = (bool)(*_ppPath)->empty ( );   
        Boolean _nrv = (Boolean)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Methods::Montecarlo::CPath::Front::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppPath)->front ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
UInt64 Cephei::QL::Methods::Montecarlo::CPath::Length::get ()
{
    try
    {
    	QuantLib::Size _rv = (QuantLib::Size)(*_ppPath)->length ( );   
        UInt64 _nrv = _rv; //c1
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Methods::Montecarlo::CPath::Time (UInt64 i)
{
    try
    {
        QuantLib::Size _i = (QuantLib::Size)ValueHelper::Convert (i); //a
    	QuantLib::Time _rv = (QuantLib::Time)(*_ppPath)->time ( _i );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::ITimeGrid^ Cephei::QL::Methods::Montecarlo::CPath::TimeGrid::get ()
{
    try
    {
    	QuantLib::TimeGrid& _rv = (QuantLib::TimeGrid&)(*_ppPath)->timeGrid ( );   
        Cephei::QL::CTimeGrid^ _nrv = REFNEW Cephei::QL::CTimeGrid (_rv, this);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Methods::Montecarlo::CPath::Value (UInt64 i)
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
        QuantLib::Size _i = (QuantLib::Size)ValueHelper::Convert (i); //a
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppPath)->value ( _i );   
        Double _nrv = (Double)ValueHelper::Convert (_rv); //c
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String(_error.what()));
        else
		    throw REFNEW NativeExcpetion (REFNEW PLATFORM::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Methods::Montecarlo::CPathVector::CPathVector ()
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
}
Cephei::QL::Methods::Montecarlo::CPathVector::~CPathVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
	_pVValue = NULL;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
	_pVBoost = NULL;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
	_pVHand = NULL;
#endif
}
Cephei::QL::Methods::Montecarlo::CPathVector::!CPathVector ()
{
#ifdef STRUCT
	if (_pVValue != NULL) delete _pVValue;
#endif   
	if (_pVBoost != NULL) delete _pVBoost;
#ifdef HANDLE
	if (_pVHand != NULL) delete _pVHand;
#endif
}
#ifdef STRUCT
Cephei::QL::Methods::Montecarlo::CPathVector::CPathVector (std::vector<QuantLib::Path>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = &vec;
	_owner = owner;
}
Cephei::QL::Methods::Montecarlo::CPathVector::CPathVector (std::vector<QuantLib::Path> vec)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	_pVValue = new std::vector<QuantLib::Path> (vec);
}
#endif
Cephei::QL::Methods::Montecarlo::CPathVector::CPathVector (std::vector<boost::shared_ptr<QuantLib::Path>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVBoost = &vec;
	_owner = owner;
}
#ifdef HANDLE
Cephei::QL::Methods::Montecarlo::CPathVector::CPathVector (std::vector<QuantLib::Handle<QuantLib::Path>>& vec, Object^ owner)
{
#ifdef STRUCT
	_pVValue = NULL;
#endif
	_pVBoost = NULL;
#ifdef HANDLE
	_pVHand = NULL;
#endif
	 _pVHand = &vec;
	_owner = owner;
}
#endif

int Cephei::QL::Methods::Montecarlo::CPathVector::Count::get ()
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
		return _pVValue->size();
	}
#endif    
	if (_pVBoost != NULL)
	{
		return _pVBoost->size ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		return _pVHand->size ();
	}
#endif
	return 0;		// should never happen
}
Cephei::QL::Methods::Montecarlo::IPath^ Cephei::QL::Methods::Montecarlo::CPathVector::default::get (int index) 
{
#ifdef STRUCT
	if (_pVValue != NULL) 
	{
    	if ((size_t)index >= _pVValue->size()) throw REFNEW RangeException ();
		QuantLib::Path& native = (*_pVValue)[index];
		return REFNEW CPath (native, this);
	}
#endif    
	if (_pVBoost != NULL)
	{
    	if ((size_t)index >= _pVBoost->size()) throw REFNEW RangeException ();
		QuantLib::Path& native = *(*_pVBoost)[index];
		return REFNEW CPath (native, this);
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
    	if ((size_t)index >= _pVHand->size()) throw REFNEW RangeException ();
		QuantLib::Path& native = *((*_pVHand)[index].currentLink ());
		return REFNEW CPath (native, this);
	}
#endif
	return nullptr;		// can never be the case
}
void Cephei::QL::Methods::Montecarlo::CPathVector::default::set (int index, Cephei::QL::Methods::Montecarlo::IPath^ value) 
{
#ifdef STRUCT
	if (_pVValue != NULL)
	{
		if (_pVValue->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVValue->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVValue->push_back (dynamic_cast<CPath^>(value)->GetReference ());
		}
        else
        {
            QuantLib::Path& c = (*_pVValue)[index];
            c = dynamic_cast<CPath^>(value)->GetReference ();
        }
	}
#endif   
	if (_pVBoost != NULL)
	{
		if (_pVBoost->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVBoost->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVBoost->push_back (dynamic_cast<CPath^>(value)->GetShared ());
		}
		boost::shared_ptr<QuantLib::Path>& c = (*_pVBoost)[index];
		c = dynamic_cast<CPath^>(value)->GetShared ();
	}
#ifdef HANDLE
	if (_pVHand != NULL)
	{
		if (_pVHand->size() <= (size_t)index)
		{
			// can't happen because vectors are filled from List<> sequentially
			if (_pVHand->size() < (size_t)index)
			{
				throw REFNEW RangeException ();
			}
			_pVHand->push_back (QuantLib::Handle<QuantLib::Path> ());
		}
		QuantLib::Handle<QuantLib::Path>& c = (*_pVHand)[index];
		boost::shared_ptr<QuantLib::Path>& b = static_cast<boost::shared_ptr<QuantLib::Path>>(c.currentLink());
		b = dynamic_cast<CPath^>(value)->GetShared ();
	}
#endif
}
Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^ Cephei::QL::Methods::Montecarlo::CPathVector::CItem::get (int index) 
{
	return CellFactory::Instance->Create<IPath^> (dynamic_cast<IPath^>(default[index]));
}

void Cephei::QL::Methods::Montecarlo::CPathVector::CItem::set (int index, Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^ value) 
{
	default[index] = safe_cast<IPath^>(value->Value);
}
#ifdef STRUCT
std::vector<QuantLib::Path>& Cephei::QL::Methods::Montecarlo::CPathVector::GetReference ()
{
	 return *_pVValue;
}
#endif

std::vector<boost::shared_ptr<QuantLib::Path>>& Cephei::QL::Methods::Montecarlo::CPathVector::GetShared ()
{
	return *_pVBoost;
}

#ifdef HANDLE
std::vector<QuantLib::Handle<QuantLib::Path>>& Cephei::QL::Methods::Montecarlo::CPathVector::GetHandle ()
{
	return *_pVHand;
}
#endif
bool Cephei::QL::Methods::Montecarlo::CPathVector::PrepareFeature (NativeFeature feature)
{
	switch (feature)
	{
#ifdef STRUCT
		case NativeFeature::Value :
			if (_pVValue == NULL)
			{
				_pVValue = new std::vector<QuantLib::Path> ();
				return true;
			}
			break;
#endif
        case NativeFeature::shared_ptr :
			if (_pVBoost == NULL)
			{
				_pVBoost = new std::vector<boost::shared_ptr<QuantLib::Path>> ();
				return true;
			}
			break;
#ifdef HANDLE
        case NativeFeature::Handle :
            if (_pVHand == NULL)
            {
                _pVHand = new std::vector<QuantLib::Handle<QuantLib::Path>> ();
                return true;
            }
            break;
#endif
	}
	return false;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Methods::Montecarlo::IPath^ Cephei::QL::Methods::Montecarlo::CPath_Factory::Create (Cephei::QL::ITimeGrid^ timeGrid, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Math::IArray^>^ values)
{
    return REFNEW CPath ( timeGrid,  values);
}
/* <summary>Create a single dimension array of Path that can be passed into other function </summary> */
IVector<Cephei::QL::Methods::Montecarlo::IPath^>^ Cephei::QL::Methods::Montecarlo::CPath_Factory::CreateVector ()
 {
	 return REFNEW CoVector<IPath^> (REFNEW CPathVector ());
 }
IVector<Cephei::QL::Methods::Montecarlo::IPath^>^ Cephei::QL::Methods::Montecarlo::CPath_Factory::CreateVector (PLATFORM::Collections::Generic::IEnumerable<IPath^>^ source)
 {
	 return REFNEW CoVector<IPath^> (source, REFNEW CPathVector ());
 }
/* <summary>Create a single dimension array of Path with change events</summary> */
Cephei::Core::Generic::ICoCell<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^>^>^ Cephei::QL::Methods::Montecarlo::CPath_Factory::CreateCellVector ()
 {
	 return CellFactory::Instance->Create<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^>^> (REFNEW CoCellVector<Cephei::QL::Methods::Montecarlo::IPath^> (REFNEW CPathVector ()));
 }
Cephei::Core::Generic::ICoCell<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^>^>^ Cephei::QL::Methods::Montecarlo::CPath_Factory::CreateCellVector (PLATFORM::Collections::Generic::IEnumerable<Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^>^ source)
 {
	 return CellFactory::Instance->Create<IVector<Cephei::Core::Generic::ICoCell<Cephei::QL::Methods::Montecarlo::IPath^>^>^> (REFNEW CoCellVector<Cephei::QL::Methods::Montecarlo::IPath^> (source, REFNEW CPathVector ()));
 }

